#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <set> 

using namespace std;
using LL = long long;

const int N = 1e6 + 10;

LL n, m, k;
multiset<LL> l, r;
LL A[N];

LL pop_front(multiset<LL>& q){
    auto it = q.begin();
    LL val = (*it);
    q.erase(it);
    return val;
}

LL pop_back(multiset<LL>& q){
    auto it = prev(q.end());
    LL val = (*it);
    q.erase(it);
    return val;
}



int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    LL tot = 0;

    cin >> n >> m >> k;
    for(int i = 1; i <= n; i ++) cin >> A[i];

    for(int i = 1; i <= m; i ++){
        tot = tot + A[i];

        l.insert(A[i]);

        if(l.size() > k){
            LL val = pop_back(l);
            tot -= val;
            r.insert(val);
        }
    }
  
    cout << tot << " ";
    for(int i = m + 1; i <= n; i ++){
        l.insert(A[i]);
        tot += A[i];

        LL val = pop_back(l);
        r.insert(val);
        tot -= val;

        if(r.find(A[i - m]) != r.end()){
            auto it = r.find(A[i - m]);
            r.erase(it);
        }else{
            auto it = l.find(A[i - m]);
            tot -= (*it);
            l.erase(it);

            LL temp = pop_front(r);
            tot += temp;
            l.insert(temp);

        }

        cout << tot << " ";
    }


    return 0;
}